<template>
  <el-container class="goods-stock">
    <el-main>
      <el-form :model="form.model" :rules="form.rules" ref="formRef" label-width="1px">
        <el-form-item label="" prop="refuse_msg">
          <el-input
            v-model="form.model.refuse_msg"
            autosize
            type="textarea"
            placeholder="请输入拒绝理由"
          />
        </el-form-item>
      </el-form>
    </el-main>
    <el-footer class="sa-footer--submit">
      <el-button type="primary" @click="confirm">确 定</el-button>
    </el-footer>
  </el-container>
</template>
<script setup>
  import { cloneDeep } from 'lodash';
  import { onMounted, reactive, ref, unref } from 'vue';
  import { api } from './withdraw.service';
  const emit = defineEmits(['modalCallBack']);
  const props = defineProps({
    modal: {
      type: Object,
    },
  });
  const loading = ref(false);
  // 添加 编辑 form
  let formRef = ref(null);
  const form = reactive({
    model: {
      refuse_msg: '',
    },
    rules: {
      refuse_msg: [{ required: true, message: '请输入拒绝理由', trigger: 'blur' }],
    },
  });
  async function confirm() {
    // 表单验证
    unref(formRef).validate(async (valid) => {
      if (!valid) return;
      form.model['action'] = 'refuse';
      let submitForm = cloneDeep(form.model);
      const { error } = await api.handle(props.modal.params.id, submitForm);
      if (error == 0) {
        emit('modalCallBack', {
          event: 'confirm',
        });
      }
    });
  }
</script>
<style lang="scss" scoped>
  .goods-stock {
    .addstock-title {
      font-size: 12px;
      margin: 0 16px 0 8px;
      line-height: 22px;
      color: var(--sa-font);
    }
    .addstock-input {
      width: 160px;
    }
    .sku-table-wrap {
      width: 100%;
      overflow: auto;
      margin-top: 16px;
      .sku-table {
        width: 100%;
        border: 1px solid var(--sa-border);
        th {
          font-size: 12px;
          color: var(--subtitle);
          height: 32px;
          line-height: 1;
          padding-left: 12px;
          box-sizing: border-box;
          text-align: left;
          .sku-table-header-title {
            margin-right: 10px;
          }
          .th-title {
            font-size: 12px;
            color: var(--subtitle);
            font-weight: bold;
          }
        }
        td {
          min-width: 88px;
          padding: 0 10px;
          height: 40px;
          box-sizing: border-box;
          &.image {
            min-width: 48px;
          }
          &.stock {
            min-width: 190px;
            .stock-title {
              margin-right: 12px;
            }
            .addsku-input {
              width: 80px;
            }
          }
          &.stock_warning {
            min-width: 168px;
          }
          &.sn {
            min-width: 116px;
          }
        }
      }
    }
  }
  .alledit-input {
    margin-bottom: 10px;
  }
  .batch-icon {
    width: 12px;
    height: 12px;
    margin-left: 10px;
    color: var(--el-color-primary);
  }
</style>
